package cn.emailChat.ai.config;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * @Description 配置网络代理
 * @Author susu
 * @Date 2025/8/18
 */
@Configuration
public class ProxyConfig {

    @Value("${proxy.socks.host:}")
    private String proxyHost;

    @Value("${proxy.socks.port:}")
    private String proxyPort;

    @PostConstruct
    public void initProxy() {
        if (proxyHost != null && !proxyHost.isEmpty() && proxyPort != null && !proxyPort.isEmpty()) {
            System.setProperty("socksProxyHost", proxyHost);
            System.setProperty("socksProxyPort", proxyPort);
            System.out.println("[ProxyConfig] 已设置 SOCKS 代理: " + proxyHost + ":" + proxyPort);
        }
    }
}
